﻿// -----------------------------------------------------------------------
// <copyright file="SendDataWebRequestState.cs" company="TaskyMedia LLC">
// Copyright (c) TaskyMedia LLC
// </copyright>
// -----------------------------------------------------------------------

namespace SohpClient
{
    using System;
    using System.Net;

    /// <summary>
    /// Contains the state of a web request when used with the asynchronous <c>Send</c>operation.
    /// </summary>
    internal class SendDataWebRequestState : WebRequestState
    {
        /// <summary>
        /// The data to be sent to the server.
        /// </summary>
        private byte[] data;

        /// <summary>
        /// Initializes a new instance of the <see cref="SendDataWebRequestState"/> class.
        /// </summary>
        /// <param name="request">The <see cref="HttpWebRequest"/> instance.</param>
        /// <param name="data">The data to be sent to the server.</param>
        /// <param name="asyncState">The user-provided asynchronous state object.</param>
        public SendDataWebRequestState(HttpWebRequest request, byte[] data, object asyncState)
            : base(request, asyncState)
        {
            this.data = data;
        }

        /// <summary>
        /// Gets the length of the data.
        /// </summary>
        /// <value>
        /// The length of the data.
        /// </value>
        public int DataLength
        {
            get
            {
                return this.data.Length;
            }
        }

        /// <summary>
        /// Gets the data to be sent.
        /// </summary>
        /// <returns>Returns a <c>byte</c> array containing the data to be sent.</returns>
        public byte[] GetData()
        {
            return this.data;
        }
    }
}
